package cn.com.open.itembank.sqlprovider;

import cn.com.open.itembank.entity.OperateLog;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * Created by lucky on 2017/7/20.
 */
public class OperateLogSqlProvider {
    private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(OperateLogSqlProvider.class);

    /**
     * Gets insert.
     *
     * @param model the model
     * @return the insert
     */
    public String insert(final OperateLog model) {

        INSERT_INTO("OperateLog");
        if (model.getId() != null) {
            VALUES("ID", "#{id}");
        }
        if (model.getUserId() != null) {
            VALUES("UserID", "#{userId}");
        }
        if (model.getOptUrl() != null) {
            VALUES("OptUrl", "#{optUrl}");
        }
        if (model.getArea() != null) {
            VALUES("Area", "#{area}");
        }
        if (model.getController() != null) {
            VALUES("Controller", "#{controller}");
        }
        if (model.getAction() != null) {
            VALUES("Action", "#{action}");
        }
        if (model.getOptType() != null) {
            VALUES("OptType", "#{optType}");
        }
        if (model.getOptTime() != null) {
            VALUES("OptTime", "#{optTime}");
        }
        if (model.getOptIp() != null) {
            VALUES("OptIP", "#{optIp}");
        }
        if (model.getOptDescription() != null) {
            VALUES("OptDescription", "#{optDescription}");
        }

        String sql = SQL();
        return sql;
    }
}
